package com.collect.collect.api.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.collect.collect.api.dao.DataMonitorMapper;
import com.collect.collect.api.dao.TableFlagMapper;
import com.collect.collect.api.entity.DataMonitor;
import com.collect.collect.api.entity.TableFlag;
import com.collect.collect.api.service.IDataMonitorService;
import com.collect.collect.api.service.ISlaveService;
import com.collect.collect.api.service.ITableFlagService;
import com.collect.collect.config.annotation.DataSource;
import com.collect.collect.config.enums.DataSourceType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Slf4j
@Service
@DataSource(value = DataSourceType.SLAVE)
public class TableFlagServiceImpl extends ServiceImpl<TableFlagMapper, TableFlag> implements ITableFlagService {

    @Autowired
    private TableFlagMapper tableFlagMapper;

    /**
     * 获取唯一标识字段名
     * @param tableName
     * @return
     */
    @Override
    public String getFlagColumn(String tableName) {
        return getOne(Wrappers.<TableFlag>lambdaQuery().eq(TableFlag::getTableName,tableName)).getIdName();
    }
}